<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习1</title>
    <style>
        table {
            border-collapse: collapse;
            margin-top: 20px;
            width: 400px;
        }

        td,
        th {
            border: 1px solid #cccccc;
            height: 20px;
        }
    </style>
</head>

<body>
    <button id="light">淡色系列</button>
    <button id="dark">深色系列</button>
    <table>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script>
        //淡色按钮点击事件
        $("#light").click(function () {
            $("table tr:nth-child(odd)").css('background-color','lightblue')
            $("table tr:nth-child(even)").css('background-color','lightpink')
        })
        //深色按钮点击事件
        $("#dark").click(function () {
            $("table tr:nth-child(odd)").css('background-color','#ccc')
            $("table tr:nth-child(even)").css('background-color','#eee')
        })
    </script>
</body>

</html>